import React, { useEffect, useState } from 'react';
import { Pagination } from 'antd';
import style from './index.module.less';
import { getFavorableDataList } from '../../../../api/publishCase';

const Publish = (props: any) => {
    const [queryParams, setQueryParams] = useState({
        pageNo: 1,
        pageSize: 10,
        total: 11,
    });
    useEffect(() => {
        getListData();
    }, [queryParams.pageNo]);
    const [list, setList] = useState([]);
    // 获取列表数据
    const getListData = async () => {
        const res: any = await getFavorableDataList({
            pageNo: queryParams.pageNo,
            pageSize: queryParams.pageSize,
        });
        setQueryParams({
            ...queryParams,
            total: res.data.total,
        });
        setList(res.data.list);
    };
    // 分页
    const handlePageChange = (page: number) => {
        setQueryParams({
            ...queryParams,
            pageNo: page,
        });
    };

    return (
        <>
            <div className={style.acknowled_body}>
                {list.map((item: any) => {
                    return (
                        <div className={style.acknowled_item} key={item.customId}>
                            <div className={style.item_right}>
                                <div className={style.right_line}>
                                    <div className={style.label}>客户信息：</div>
                                    <div className={style.desic}>{item.customInfo}</div>
                                </div>
                                <div className={style.right_line}>
                                    <div className={style.label}>就职医院：</div>
                                    <div className={style.desic}>{item.hospital}</div>
                                </div>
                                <div className={style.right_line}>
                                    <div className={style.label}>客户好评：</div>
                                    <div className={style.desic}>{item.commentContent}</div>
                                </div>
                            </div>
                        </div>
                    );
                })}
                {queryParams.total > 10 && (
                    <div className={style.pagination_body}>
                        <Pagination
                            defaultCurrent={queryParams.pageNo}
                            total={queryParams.total}
                            onChange={handlePageChange}
                        />
                    </div>
                )}
            </div>
        </>
    );
};

export default Publish;
